<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class c_login extends CI_Controller {

	function __construct(){
		parent::__construct();
		$this->load->model('m_login');
		$this->load->model('m_setup');
		checkLogin();
	}
	
	function index(){
		$task = $this->input->post("task");
		switch($task){
			case "LIST_AAN" : 
				$this->list_aan(); break;
			case "LIST_PEMASUKAN" : 
				$this->list_pemasukan(); break;
			case "LIST_KLARIFIKASI" : 
				$this->list_klarifikasi(); break;
			default : 
				
				$param_refresh = $this->m_setup->get_param("REFRESH") ;
				$data["refresh"] = $param_refresh[0]->nvalue1;
				$param_merah = $this->m_setup->get_param("MERAH") ;
				$data["merah"] = $param_merah[0]->nvalue1;
				$param_kuning = $this->m_setup->get_param("KUNING") ;
				$data["kuning"] = $param_kuning[0]->nvalue1;
				$param_hijau = $this->m_setup->get_param("HIJAU") ;
				$data["hijau"] = $param_hijau[0]->nvalue1;
				$this->load->view('template/v_login',$data);
		}
	}
	
	function list_aan(){
		$data = $this->m_login->list_aan();
		echo json_encode($data);
	}
	
	function list_pemasukan(){
		$data = $this->m_login->list_pemasukan();
		echo json_encode($data);
	}
	
	function list_klarifikasi(){
		$data = $this->m_login->list_klarifikasi();
		echo json_encode($data);
	}
	
	function process(){
		$login_username = $this->input->post('login_username');
		$login_password = $this->input->post('login_password');
		
		$data = $this->m_login->process($login_username,$login_password);
		
		echo json_encode($data);
	}
	
	function logout(){
		// echo $this->session->userdata('administrator');
		setLogout();
	}

}